import { ObjCreate } from "../../common/ObjCreate";
import { FlyFootBmp } from "./FlyFootBmp";
import { AIManager } from "../../../scene/ai/AIManager";
import { AIType } from "../../../scene/ai/AIType";
import { TaskTargetInfo } from "../../../model/TaskTargetInfo";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
//class FlyFootTxt
    
    export  class FlyFootTxt /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._text = ObjCreate.createTextField("", 0, 0);
            this._text.textColor = 65280;
            this._text.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._text.addEventListener(flash.events.TextEvent.LINK, this.onTextLinkHandler);
            addChild(this._text);
            this._flyFoot = new FlyFootBmp();
            this._flyFoot.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyBmpClickHandler);
            addChild(this._flyFoot);
            return;
        }

        /* internal  */onTextLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            if (this._target) 
            {
                AIManager.onAutoPathAIControl(this._target);
            }
            return;
        }

        /* internal  */onFlyBmpClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._target) 
            {
                AIManager.onAIControl(this._target, AIType.AI_Convey);
            }
            return;
        }

        public updateData(arg1: TaskTargetInfo): void
        {
            if (arg1) 
            {
                this._target = arg1;
                this._text.htmlText = "<u><a href=\'event: 0\'>" + HTMLUtil.addColor(arg1.name, "#00ff00") + "</a></u>";
                this._flyFoot.x = this._text.x + this._text.textWidth + 2;
            }
            return;
        }

        protected /* var */_text: Object /* flash.text.TextField */;

        protected /* var */_flyFoot: FlyFootBmp;

        protected /* var */_target: TaskTargetInfo;
    }
